# 父类
class Car():
    def __init__(self, maker, model, year):
        self.maker = maker
        self.model = model
        self.year = year
        self.meter = "0"

    def showInfo(self):
        print('这是一台' + self.year + '由' + self.maker + '生产的车, 型号为' +
              self.model + ', 已行驶里程' + self.meter + '米.')

    def updateMeter(self, meter):
        self.meter = meter


Audi = Car('Audi', 'A6L', '2016')
Audi.showInfo()
# 这是一台2016由Audi生产的车, 型号为A6L, 已行驶里程0米.


# 子类, 继承父类
class ElectricCar(Car):

    def __init__(self, maker, model, year):
        super().__init__(maker, model, year)
        self.battery_size = "70"

    def showBattry(self):
        print('当前电量为: ' + self.battery_size + '-KWh battery.')

    def setBattery(self, str):
        self.battery_size = str
        return self.battery_size


myTesla = ElectricCar('tesla', 'model S', '2019')
myTesla.showInfo()
# 这是一台2019由tesla生产的车, 型号为model S, 已行驶里程0米.
myTesla.showBattry()
# 当前电量为: 70-KWh battery.

currentBatterySize = myTesla.setBattery('100')
print ('当前剩余电量为: ' + currentBatterySize + '%.')
# 当前剩余电量为: 100%.